﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MDK.Common
{
    public class WriteTxt
    {
        static string _path = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)+"\\交接记录";
        /// <summary>
        ///导出已交接试管
        /// </summary>
        /// <param name="DonCode"></param>
        public static void WriteCode(string DonCode)
        {
            if (Directory.Exists(_path) == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory(_path);
            }
            int inter = 0;
            try
            {
                string[] allLines = File.ReadAllLines($"{_path}\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                inter = allLines.Length;
            }
            catch { }
            StreamWriter sw = new StreamWriter($"{_path}\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt", true);
            sw.WriteLine($"{( inter+1)}=" + DonCode);
            sw.Close();//写入
        }
    }
}
